home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk2.zip / LZTEST.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  2KB  |  62 lines

  1. ;
  2. ; *** Listing 2-6 ***
  3. ;
  4. ; Program to measure performance of code that takes longer than
  5. ; 54 ms to execute. (LZTEST.ASM)
  6. ;
  7. ; Link with LZTIMER.ASM (Listing 2-5). LZTEST.BAT (Listing 2-7)
  8. ; can be used to assemble and link both files. Code to be
  9. ; measured must be in the file TESTCODE; Listing 2-8 shows
  10. ; a sample TESTCODE file.
  11. ;
  12. ; By Michael Abrash 4/26/89
  13. ;
  14. mystack    segment    para stack 'STACK'
  15.     db    512 dup(?)
  16. mystack    ends
  17. ;
  18. Code    segment    para public 'CODE'
  19.     assume    cs:Code, ds:Code
  20.     extrn    ZTimerOn:near, ZTimerOff:near, ZTimerReport:near
  21. Start    proc    near
  22.     push    cs
  23.     pop    ds    ;point DS to the code segment,
  24.             ; so data as well as code can easily
  25.             ; be included in TESTCODE
  26. ;
  27. ; Delay for 6-7 seconds, to let the Enter keystroke that started the
  28. ; program come back up.
  29. ;
  30.     mov    ah,2ch
  31.     int    21h        ;get the current time
  32.     mov    bh,dh        ;set the current time aside
  33. DelayLoop:
  34.     mov    ah,2ch
  35.     push    bx        ;preserve start time
  36.     int    21h        ;get time
  37.     pop    bx        ;retrieve start time
  38.     cmp    dh,bh        ;is the new seconds count less than
  39.                 ; the start seconds count?
  40.     jnb    CheckDelayTime    ;no
  41.     add    dh,60        ;yes, a minute must have turned over,
  42.                 ; so add one minute
  43. CheckDelayTime:
  44.     sub    dh,bh        ;get time that's passed
  45.     cmp    dh,7        ;has it been more than 6 seconds yet?
  46.     jb    DelayLoop    ;not yet
  47. ;
  48.     include    TESTCODE     ;code to be measured, including calls
  49.                 ; to ZTimerOn and ZTimerOff
  50. ;
  51. ; Display the results.
  52. ;
  53.     call    ZTimerReport
  54. ;
  55. ; Terminate the program.
  56. ;
  57.     mov    ah,4ch
  58.     int    21h
  59. Start    endp
  60. Code    ends
  61.     end    Start
  62.